#include "base/Response.h"
#include "util/Logger.h"
#include <cstring>

NEW_DELETE_OPERATORS_CPP(Response,100);

char const* Response::toString () const {
    char const* flagStr = "##ERR";
    switch (getFlag()) {
    case RESPONSE_DONE:
        flagStr = "DONE"; break;
    case RESPONSE_NACK_RETRY:
        flagStr = "NACK_RETRY"; break;
    case RESPONSE_NACK_ABORT:
        flagStr = "NACK_ABORT"; break;
    case RESPONSE_NACK_BLOCK:
        flagStr = "NACK_BLOCK"; break;
    case RESPONSE_NACK_CONFLICT:
        flagStr = "NACK_CONFLICT"; break;
    case RESPONSE_NACK_SNAPSHOT_DATA:
        flagStr = "NACK_SDATA"; break;
    case RESPONSE_SNOOP_RESPONSE:
        flagStr = "SNOOP_RESP"; break;
    case RESPONSE_NO_SNOOP_RESPONSE:
        flagStr = "NO_SNOOP_RESP"; break;
    }

    char tmp[512];
    strcpy(tmp, Packet::toString());
    sim_sprintf((char*)string, "RESP %s[req:%s,flag:%s]", tmp, request->toString(), flagStr);
    return string;
}
